package org.zxyj.system.type;

import org.apache.commons.lang3.StringUtils;
import org.zxyj.system.domain.Resource;

/**
 * @author zhaoyong
 * @version 2016年2月19日
 */
public enum ResourceType {

	/** 菜单 */
	MENU {
		@Override
		public String assemblePermission(Resource resource) {
			String url = resource.getUrl();
			return this.name()
					+ (StringUtils.isEmpty(url) ? ":" + resource.getId() : StringUtils.join(url.split("/"), ":"));
		}
	},
	/** 页面 */
	PAGE {
		@Override
		public String assemblePermission(Resource resource) {
			return this.name() + resource.getId();
		}
	},
	/** 操作 */
	OPERATOR {
		@Override
		public String assemblePermission(Resource resource) {
			return resource.getPrivilege();
		}
	};

	public abstract String assemblePermission(Resource resource);

}